<?php
/**
 * +--------------------------------------------------------+
 * @Created by Phpstorm.
 * @Category StockPeCommand.php
 * @Depiction
 * @Author hwy <429208948@qq.com>
 * @Date 2022/6/30  16:16
 * +--------------------------------------------------------+
 */

namespace App\Console\Commands;


use App\Services\MyStockService;
use Illuminate\Console\Command;

class StockPeCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:stockpea';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'pe/pb/dv数据';

    private $myStockService;

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct(MyStockService $myStockService)
    {
        parent::__construct();

        $this->myStockService = $myStockService;
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $this->info("获取开始..." . date('Y-m-d H:i:s'));


        if (class_exists('\App\Util\Stock')) {
            $stock_list = $this->myStockService->getStocks(2);

            $data = (new \App\Util\Stock())->addPeDataReal($stock_list);

            $this->myStockService->addPeas($data);
        }

        $this->info("获取结束..." . date('Y-m-d H:i:s'));
    }
}
